***********************************************************************
 THIS CODE AND INFORMATION IS PROVIDED TO YOU FOR YOUR REFERENTIAL 
 PURPOSES ONLY, AND IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
 EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 
 WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE, 
 AND MAY NOT BE REDISTRIBUTED IN ANY MANNER.
 
 Copyright (c) 2004  Microsoft Corporation.  All rights reserved.
***********************************************************************

MigrateToCM.wsf Readme File

This Folder contains the scripts used to migrate users and 
websites from a standalone server based implementation to a 
centrally managed (using Active Directory and the Micrososft
Provisioning System) implementation.

Prerquesites:
Implementation of the Centralized Management and Service Provisioning
Chapters from the Solution for Windows Based Hosting 3.0.

The List of Files used by the Main Script MigrateToCM.WSF

\MigrateToCM.wsf    ........................................ Main Script. Use cscript.exe to run it. Use the /? Parameter for Syntax Information
\provreq.vbs        ........................................ Handles the Communication with the MPF Engine Server.
\ReACL.vbs          ........................................ Has the Routines for changing the ACLs on the Web Content.
\RunCMD.hta         ........................................ Used by the JoinDomain() Method to request the Passwords needed for Joining the Standalone server to the domain.
\xml\AD\ChangeUserPassword.xml  ............................ MPF Request Template to change a users password (requires the old password)
\xml\AD\CreateGroup.xml         ............................ MPF Request Template to create a group
\xml\AD\CreateOrganization.xml  ............................ MPF Request Template to create a customer organization
\xml\AD\CreateUser.xml          ............................ MPF Request Template to create a user
\xml\AD\DeleteGroup.xml         ............................ MPF Request Template to delete a group
\xml\AD\DeleteOrganization.xml  ............................ MPF Request Template to delete a customer organization
\xml\AD\DeleteUser.xml          ............................ MPF Request Template to delete a user
\xml\AD\DisableUser.xml         ............................ MPF Request Template to disable a user sccount
\xml\AD\EnableUser.xml          ............................ MPF Request Template to enable a user account
\xml\AD\getforeignownerorg.xml  ............................ MPF Request Template to the owner of an organization
\xml\AD\getthisorganizationroot.xml ........................ MPF Request Template to get the organization's ADS Path
\xml\AD\GroupAdd.xml            ............................ MPF Request Template to add an account to a group
\xml\AD\GroupRemove.xml         ............................ MPF Request Template to remove an account from a group
\xml\AD\ModifyGroup.xml         ............................ MPF Request Template to modify a group
\xml\AD\ModifyOrganization.xml  ............................ MPF Request Template to modify a customer organization
\xml\AD\ModifyUser.xml          ............................ MPF Request Template to modufy a user object
\xml\AD\MoveObject.xml          ............................ MPF Request Template to move an object in Active Directory
\xml\AD\RenameGroup.xml         ............................ MPF Request Template to rename a group
\xml\AD\RenameOrganizationalUnit.xml ....................... MPF Request Template to rename a customer organization
\xml\AD\RenameUser.xml          ............................ MPF Request Template to rename a user object
\xml\AD\SetUserPassword.xml     ............................ MPF Request Template to Set the password for a user account (requires Domain or Account Administrator Rights)


Functional Description for the Scripts:

File: MigrateToCM.wsf
Function VerifyLocalUser(strAlias)
Verify if Local user Exists on Source Server specified in Commandline
Uses ADSI to attempt to bind to object,
Returns bool true/false

Function MigrateUser(strUserName)
Main migration routine for users.
Calls also MigrateGroup to migratge the groups the user belongs to
Also ReACLs the WebRoot Folder specified on the command line

Function MigrateGroup(objGroup,strRoot)
Migrates Local Group to AD into the OU specified

Function VerifyLDAPPath(strPath)
Verifies existence of object in AD by attempting an ADSI Bind to the object
Returns true/false and the error code in case of failure

Function Finalize()
Close all files and end the script

Function Reboot(strComputer)
Reboot a given remote computer using shutdown.exe

Function Write (str2Write)
Write text to StdOut and Log File

Function SetRunOnce()
Set the script to runonce if run from the Source Computer so it is restarted after the 
Domain Join

Function JoinDomain(strDomain, strComputer)
Join the remote compter to the target domain

Function RunFromHTA(strCMD)
Run an external script from the HTA and ask for passwords first. 
Used by the JoinDomain Routine

Function IsDomainMember(strComputer)
Check if the computer is a member of the target domain
If not join it to the domain and restart the source server

Function ParseCommandLine()
Parse the commandline, basic verification and assign parameters to global variables

Function CreatePassword(strUser)
Create a random password for the newly created user and store it into pwd.log in the script path

Function VerifyMPFClient
Verify if the MPF Client COM Components are installed on the machine running the script

Function DisplaySyntax()
Show how to call the script



File: provreq.vbs

Function CreateOrganization(xi_OrgName, xi_PolicyType, xi_Description, xi_strContPath)
Create a MPF Request to Managed Active Directory to create a new Organozation

Function CreateUser(xi_strUPN, xi_strDisplayName, xi_strFName, xi_strLName, xi_strPolicy, xi_strContainer)
Create a MPF Request to Managed Active Directory to create a user in the new Organization

Function SubmitMPFRequest(xi_strXMLRequest, xi_strNamespace, xi_strProcedure)
Submit a request to MPF

Function EnableUser(xi_strUser)
Create a MPF Request to Managed Active Directory to enable a user

Function SetPassword(xi_strUser, xi_strNewPwd)
Create a MPF Request to Managed Active Directory to set the password for a user

Function GroupAdd(xi_strGroup, xi_strUser)
Create a MPF Request to Managed Active Directory to add a user to a group in AD

Function CreateGroup(xi_strGroupName, xi_strPolicy, xi_strGroupType, xi_strDescription, xi_intRolePriority, xi_strContPath)
Create a MPF Request to Managed Active Directory to create a Domain Group

File: ReACL.vbs

Function ReACLSite(strRootFolder,strSourceServer,strOldUser,strNewUser,bRemoveOld)
Get the Current Folder List into a Dictionary
we only care about Folders, Files should inherit the ACLs from the Folder
we will only go in and add the new user by default. set bRemoveOld to True
if you want to remove the user from the ACL
get the AccessMask for the old User
create a new ACE and add the new user from AD and the AccessMask and AccessType from the old user to the ACL.

Function GetSID(strDomain,strAlias)
To ensure we always catch the right trustee in the ACE of the WebRoot Folder we need to match SIDs


File: RunCMD.hta

Takes a commandline, asks for password(s) and executes the commandline after execution completes returns control back to the caller.

Function Submit_Click
Main routine 

Function Close_Click()
Close the form without doing a thing

Function InitThis()
Initialize the form,
